Skip to content

Instantly share code, notes, and snippets.

View qunabu's full-sized avatar

Mateusz Wojczal qunabu

View GitHub Profile
@qunabu
qunabu / t.js
Created November 26, 2020 10:37
it("should add a user in memory", () => {
userManager.addUser("Dr. Falker", "Joshua");
expect(userManager.loginUser("Dr. Falker", "Joshua")).toBe(true);
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:37
it("should add a user in memory", () => {
userManager.addUser("Dr. Falker", "Joshua");
expect(userManager._users[0].name).toBe("Dr. Falker");
expect(userManager._users[0].password).toBe("Joshua");
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:36
it("should return an empty string when passed an empty string", () => {
expect(keepUniqueChars("")).toBe("");
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:35
it("should suppress all chars that appear multiple times", () => {
expect(keepUniqueChars("Hello Fostonic !!")).toBe("HeFstnic");
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:33
describe("The RPN expression evaluator", () => {
it("should return null when the expression is an empty string", () => {
const result = RPN("");
expect(result).toBeNull();
});
it("should return the same value when the expression holds a single value", () => {
const result = RPN("42");
expect(result).toBe(42);
});
it("should properly calculate an expression", () => {
@qunabu
qunabu / t.js
Created November 26, 2020 10:33
// Reverse Polish Notation, add 3 and 4, one would write 3 4 + rather than 3 + 4
it("should properly calculate a RPN expression", () => {
const result = RPN("5 1 2 + 4 * - 10 /");
expect(result).toBe(-0.7);
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:32
it('should send the profile data to the server', () => { // expect(...)to(...); });
it('should update the profile view properly', () => { // expect(...)to(...);});
@qunabu
qunabu / t.js
Created November 26, 2020 10:32
it("should send the profile data to the server and update the profile view properly", () => {
// expect(...)to(...);
// expect(...)to(...);
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:31
it("should call once a method with the proper arguments", () => {
const foo = jasmine.createSpyObj("foo", ["bar", "baz"]);
foo.bar("baz");
expect(foo.bar).toHaveBeenCalledWith("baz");
});
@qunabu
qunabu / t.js
Created November 26, 2020 10:31
it("should call a method with the proper arguments", () => {
const foo = {
bar: jasmine.createSpy(),
baz: jasmine.createSpy(),
};
foo.bar("qux");
expect(foo.bar).toHaveBeenCalled();
expect(foo.bar.calls.argsFor(0)).toEqual(["qux"]);
});