From 29cb47187d027092e092f04f6c966cf7790ffaa7 Mon Sep 17 00:00:00 2001 From: Gary Chisholm Date: Fri, 28 Oct 2016 17:47:40 +1100 Subject: [PATCH] Update: Tests and dependencies --- .travis.yml | 2 +- package.json | 13 +++++++------ tests/test-factory.test.js | 31 +++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2022962..9844372 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: node_js node_js: - - "0.11" \ No newline at end of file + - "4.6" diff --git a/package.json b/package.json index e0c5bf6..7af88c4 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,15 @@ { "name": "js-diff", - "version": "0.0.1", + "version": "0.0.2", "description": "A recursive JavaScript object comparison script", "main": "diff.js", - "dependencies": { - "karma": "~0.12.21", - "karma-jasmine": "~0.1.5", - "karma-phantomjs-launcher": "^0.1.4" + "dependencies": {}, + "devDependencies": { + "jasmine-core": "^2.5.2", + "karma": "^1.3.0", + "karma-jasmine": "^1.0.2", + "karma-phantomjs-launcher": "^1.0.2" }, - "devDependencies": {}, "scripts": { "test": "echo \"Running Karma Tests\" && ./node_modules/karma/bin/karma start karma.conf.js --single-run --browsers PhantomJS" }, diff --git a/tests/test-factory.test.js b/tests/test-factory.test.js index f262814..28b4e23 100644 --- a/tests/test-factory.test.js +++ b/tests/test-factory.test.js @@ -1,20 +1,20 @@ describe("TestFactoryTester", function() { var f = TestFactory.testObject; - + beforeEach(function(){ - spyOn(f, 'init').andCallThrough(); + spyOn(f, 'init').and.callThrough(); }); - + afterEach(function() { f.reset(); }); - + it("should be able to initialize", function() { expect(f.init).toBeDefined(); f.init(); expect(f.init).toHaveBeenCalled(); }); - + it("should initialise an empty object", function(){ f.init(); expect(typeof f.obj).toEqual("object"); @@ -43,4 +43,23 @@ describe("TestFactoryTester", function() { expect(f.isEmpty()).toEqual(true); expect(f.obj.firstName).toBeUndefined(); }); -}); \ No newline at end of file + + it("should add and remove nested objects", function(){ + f.init(); + f.add("company", { + name: "Acme", + location: "London" + }); + + expect(f.isEmpty()).toEqual(false); + expect(f.obj.company).toBeDefined(); + expect(f.obj.company.name).toBeDefined(); + expect(f.obj.company.name).toEqual("Acme"); + expect(f.obj.company.location).toEqual("London"); + + f.remove("company"); + + expect(f.isEmpty()).toEqual(true); + expect(f.obj.company).toBeUndefined(); + }); +});