Skip to content

Instantly share code, notes, and snippets.

Avatar

Mateusz Qunabu qunabu

View GitHub Profile
View t.js
it("should add a user in memory", () => {
userManager.addUser("Dr. Falker", "Joshua");
expect(userManager.loginUser("Dr. Falker", "Joshua")).toBe(true);
});
View t.js
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");
});
View t.js
it("should return an empty string when passed an empty string", () => {
expect(keepUniqueChars("")).toBe("");
});
View t.js
it("should suppress all chars that appear multiple times", () => {
expect(keepUniqueChars("Hello Fostonic !!")).toBe("HeFstnic");
});
View t.js
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", () => {
View t.js
// 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);
});
View t.js
it('should send the profile data to the server', () => { // expect(...)to(...); });
it('should update the profile view properly', () => { // expect(...)to(...);});
View t.js
it("should send the profile data to the server and update the profile view properly", () => {
// expect(...)to(...);
// expect(...)to(...);
});
View t.js
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");
});
View t.js
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"]);
});
You can’t perform that action at this time.