Skip to content

Instantly share code, notes, and snippets.

View techiediaries's full-sized avatar

Techiediaries (Now 10xdev.blog) techiediaries

View GitHub Profile
describe("MyJSUtilities", function() {
describe(">String Utils", function() {
it("should be able to lower case a string",function() {
expect().nothing();
});
it("should be able to upper case a string",function() {
expect().nothing();
});
it("should be able to confirm if a string contains a substring",function() {
const utils = require("../index.js");
it("should be able to lower case a string",function() {
expect(utils.toLowerCase).toBeDefined();
expect(utils.toLowerCase("HELLO WORLD")).toEqual("hello world");
});
describe(">String Utils", function() {
it("should be able to lower case a string",function() {
expect(utils.toLowerCase).toBeDefined();
expect(utils.toLowerCase("HELLO WORLD")).toEqual("hello world");
});
it("should be able to upper case a string",function() {
expect(utils.toUpperCase).toBeDefined();
expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD");
it("should be able to tell if a number is even",function() {
expect(utils.isEven).toBeDefined();
expect(utils.isEven(2)).toBeTruthy();
expect(utils.isEven(1)).toBeFalsy();
});
it("should be able to tell if a number is even",function() {
expect(utils.isEven).toBeDefined();
expect(utils.isEven(2)).toBeTruthy();
expect(utils.isEven(1)).toBeFalsy();
});
it("should be able to tell if a number is even",function() {
expect(utils.isEven).toBeDefined();
expect(utils.isEven(2)).toBeTruthy();
expect(utils.isEven(1)).toBeFalsy();
});
describe("/Basic Math Utils", function () {
beforeEach(function () {
jasmine.addMatchers({
hasEvenMethod: function (util, customEqualityTesters) {
return {
compare: function (actual, expected) {
var result = { pass: utils.isEven !== undefined };
if (result.pass) {
result.message = "Expected isEven() to be not defined."
}
it("should be able to upper case a string", function () {
var spytoUpperCase = spyOn(String.prototype, 'toUpperCase').and.callThrough();
expect(utils.toUpperCase).toBeDefined();
expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD");
expect(String.prototype.toUpperCase).toHaveBeenCalled();
expect(spytoUpperCase.calls.count()).toEqual(1);
});
it("should be able to upper case a string", function () {
var spytoUpperCase = spyOn(String.prototype, 'toUpperCase').and.callThrough();
expect(utils.toUpperCase).toBeDefined();
expect(utils.toUpperCase("hello world")).toEqual("HELLO WORLD");
expect(String.prototype.toUpperCase).toHaveBeenCalled();
expect(spytoUpperCase.calls.count()).toEqual(1);
});