From a9ff54e7490761a7c0ad572d060ee386179d11df Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 12 Aug 2012 23:45:00 -0700 Subject: adding test cases for Jasmine Signed-off-by: Valerio Virgillito --- tests/unit-tests/color-model-test.js | 130 ++++++ tests/unit-tests/file-io-test.js | 610 +++++++++++++++++++++++++++++ tests/unit-tests/styles-controller-test.js | 143 +++++++ 3 files changed, 883 insertions(+) create mode 100644 tests/unit-tests/color-model-test.js create mode 100644 tests/unit-tests/file-io-test.js create mode 100644 tests/unit-tests/styles-controller-test.js (limited to 'tests') diff --git a/tests/unit-tests/color-model-test.js b/tests/unit-tests/color-model-test.js new file mode 100644 index 00000000..d596445b --- /dev/null +++ b/tests/unit-tests/color-model-test.js @@ -0,0 +1,130 @@ +var Montage = require("montage/core/core").Montage; + +var cmObject = require("ninjaapp/js/models/color-model"), + cm = cmObject.ColorModel; + +console.log(cm); + +describe('ColorManager', function() { + /** **************** alpha tests **************** */ + describe('alpha', function() { + it('default is 1', function() { + expect(cm.alpha).toEqual(1); + }); + it('can be set/get', function() { + cm.alpha = 0.2; + expect(cm.alpha).toEqual(0.2); + }); + }); + + + /** **************** rgbToHex() tests **************** */ + describe('rgbToHex()', function() { + it('rgbToHex(0,0,0) is 000000/black', function() { + var hex = cm.rgbToHex(0,0,0); + expect(hex).toEqual("000000"); + }); + it('rgbToHex(255,255,255) is FFFFFF/white', function() { + var hex = cm.rgbToHex(255,255,255); + expect(hex).toEqual("FFFFFF"); + }); + it('rgbToHex(255,0,0) is FF0000/red', function() { + var hex = cm.rgbToHex(255,0,0); + expect(hex).toEqual("FF0000"); + }); + it('rgbToHex(0,255,0) is 00FF00/green', function() { + var hex = cm.rgbToHex(0,255,0); + expect(hex).toEqual("00FF00"); + }); + it('rgbToHex(0,0,255) is 0000FF/blue', function() { + var hex = cm.rgbToHex(0,0,255); + expect(hex).toEqual("0000FF"); + }); + it('rgbToHex(255,160,122) is FFA07A/salmon', function() { + var hex = cm.rgbToHex(255,160,122); + expect(hex).toEqual("FFA07A"); + }); + }); + + + /** **************** rgbToHsl() tests **************** */ + describe('rgbToHsl()', function() { + it('rgbToHsl(0,0,0) is {h:0, s:0, l:0}/black', function() { + var value = cm.rgbToHsl(0,0,0); + expect(value.h).toEqual(0); + expect(value.s).toEqual(0); + expect(value.l).toEqual(0); + }); + it('rgbToHsl(255,255,255) is {h:0, s:0, l:100}/white', function() { + var value = cm.rgbToHsl(255,255,255); + expect(value.h).toEqual(0); + expect(value.s).toEqual(0); + expect(value.l).toEqual(100); + }); + it('rgbToHsl(255,0,0) is {h:0, s:100, l:50}/red', function() { + var value = cm.rgbToHsl(255,0,0); + expect(value.h).toEqual(0); + expect(value.s).toEqual(100); + expect(value.l).toEqual(50); + }); + it('rgbToHsl(0,255,0) is {h:120, s:100, l:50}/green', function() { + var value = cm.rgbToHsl(0,255,0); + expect(value.h).toEqual(120); + expect(value.s).toEqual(100); + expect(value.l).toEqual(50); + }); + it('rgbToHsl(0,0,255) is {h:240, s:100, l:50}/blue', function() { + var value = cm.rgbToHsl(0,0,255); + expect(value.h).toEqual(240); + expect(value.s).toEqual(100); + expect(value.l).toEqual(50); + }); + it('rgbToHsl(255,160,122) is {h:17.14, s:100, l:73.92}/salmon', function() { + var value = cm.rgbToHsl(255,160,122); + expect(value.h).toEqual(17.142857142857142); + expect(value.s).toEqual(100); + expect(value.l).toEqual(73.92156862745098); + }); + }); + + + /** **************** hexToRgb() tests **************** */ + describe('hexToRgb()', function() { + it('hexToRgb(000000) is {r:0, g:0, b:0}', function() { + var value = cm.hexToRgb("000000"); + expect(value.r).toEqual(0); // red channel + expect(value.g).toEqual(0); // green channel + expect(value.b).toEqual(0); // blue channel + }); + it('hexToRgb(FFFFFF) is {r:255, g:255, b:255}', function() { + var value = cm.hexToRgb("FFFFFF"); + expect(value.r).toEqual(255); // red channel + expect(value.g).toEqual(255); // green channel + expect(value.b).toEqual(255); // blue channel + }); + it('hexToRgb(FF0000) is {r:255, g:0, b:0}', function() { + var value = cm.hexToRgb("FF0000"); + expect(value.r).toEqual(255); // red channel + expect(value.g).toEqual(0); // green channel + expect(value.b).toEqual(0); // blue channel + }); + it('hexToRgb(00FF00) is {r:0, g:255, b:0}', function() { + var value = cm.hexToRgb("00FF00"); + expect(value.r).toEqual(0); // red channel + expect(value.g).toEqual(255); // green channel + expect(value.b).toEqual(0); // blue channel + }); + it('hexToRgb(0000FF) is {r:0, g:0, b:255}', function() { + var value = cm.hexToRgb("0000FF"); + expect(value.r).toEqual(0); // red channel + expect(value.g).toEqual(0); // green channel + expect(value.b).toEqual(255); // blue channel + }); + it('hexToRgb(FFA07A) is {r:255, g:160, b:122}', function() { + var value = cm.hexToRgb("FFA07A"); + expect(value.r).toEqual(255); // red channel + expect(value.g).toEqual(160); // green channel + expect(value.b).toEqual(122); // blue channel + }); + }); +}); \ No newline at end of file diff --git a/tests/unit-tests/file-io-test.js b/tests/unit-tests/file-io-test.js new file mode 100644 index 00000000..5b197d16 --- /dev/null +++ b/tests/unit-tests/file-io-test.js @@ -0,0 +1,610 @@ +var Montage = require("montage/core/core").Montage; +var cmObject = require("ninjaapp/js/io/system/coreioapi"), + cm = cmObject.CoreIoApi, + rootPath1 = "Users/kfg834/Documents/Ninja Projects/FTest1/", //specify any path within your ninja projects root folder + rootPath2 = "Users/kfg834/Documents/Ninja Projects/FTest2/", + InitDirPath1 = "Users/kfg834/Documents/Ninja Projects/"; + +describe('Shell API', function() { + + describe('File IO', function() { + + // File Create Tests + describe('File Create Tests', function() { + + it('Create File', function() { + Creating Initial Main Directories in the documents folder + var dir = {uri:InitDirPath1 + "FTest1"}; + var retVal = cm.createDirectory(dir); + var dir = {uri:InitDirPath1 + "FileTest2"}; + var retVal = cm.createDirectory(dir); + + var file = {uri:rootPath1 + "NewFile1.txt"}; + + var retVal = cm.createFile(file); + console.log("First create returned:" + retVal.status); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(201); + + }); + + + it('Create Existing File', function() { + + var file = {uri:rootPath1 + "NewFile1.txt"}; + var retVal = cm.createFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(400); + + //Cleaning up the files by deleting after each test + var file = {uri:rootPath1 + "NewFile1.txt"}; + var retVal = cm.deleteFile(file); + + }); + + }); + + + // File Delete + describe('File Delete Tests', function() { + + it('Delete File', function() { + + //Set up + var file = {uri:rootPath1 + "NewFile1.txt"}; + var retVal = cm.createFile(file); + + var file = {uri:rootPath1 + "NewFile1.txt"}; + var retVal = cm.deleteFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + }); + + + // File Exists test + describe('File Exists Tests', function() { + + it('File Exists', function() { + + //Set up + var file = {uri:rootPath1 + "NewFile1.txt"}; + var retVal = cm.createFile(file); + console.log("Called createFile for Exists which returned " + retVal); + + var file = {uri:rootPath1 + "NewFile1.txt"}; + + var retVal = cm.fileExists(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + it('File Does Not Exist', function() { + + var file = {uri:rootPath1 +"NewFile2.txt"}; + + var retVal = cm.fileExists(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(404); + + //Clean up + var file = {uri:rootPath1 + "NewFile1.txt"}; + var retVal = cm.deleteFile(file); + + }); + + }); + + + + // Copy a file + describe('File Copy Tests', function() { + + it('Copy File', function() { + + //Set up + var file = {uri:rootPath1 + "FileCopy.txt"}; + var retVal = cm.createFile(file); + console.log("Called createFile for Copy which returned " + retVal); + + var file = {sourceUri: "/"+ rootPath1 + "FileCopy.txt", destUri: rootPath2 + "FileCopy.txt"}; + + var retVal = cm.copyFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + it('Copy File To The Same Directory', function() { + + var file = {sourceUri: "/" + rootPath1 + "FileCopy.txt", destUri: rootPath2 + "FileCopy.txt"}; + + var retVal = cm.copyFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).not.toEqual(204); + + }); + + it('Copy File To Another Directory Containing A File With The Same Name', function() { + + var file = {sourceUri:"/"+rootPath1 +"FileCopy.txt", destUri: rootPath2 + "FileCopy.txt"}; + + var retVal = cm.copyFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).not.toEqual(204); + + //Clean up + var file = {uri:rootPath1 + "FileCopy.txt"}; + var retVal = cm.deleteFile(file); + var file = {uri:rootPath2 + "FileCopy.txt"}; + var retVal = cm.deleteFile(file); + + }); + + }); + + + // Move a file + describe('File Move Tests', function() { + + it('Move File', function() { + + var file = {uri:rootPath1+"FileMove.txt"}; + var retVal = cm.createFile(file); + console.log("Called createFile for Move which returned " + retVal); + + var file = {sourceUri:"/" + rootPath1+"FileMove.txt", destUri: rootPath2+"FileMove.txt"}; + + var retVal = cm.moveFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + + it('Move File To The Same Location', function() { + + var file = {sourceUri:"/" +rootPath2+"FileMove.txt", destUri: rootPath2+"FileMove.txt"}; + + var retVal = cm.moveFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).not.toEqual(204); + + var file = {uri:rootPath2 + "FileMove.txt"}; + var retVal = cm.deleteFile(file); + + }); + + }); + + // Update a file + describe('File Update Tests', function() { + + it('Update File', function() { + + var file = {uri:rootPath1+"FileUpdate.txt"}; + var retVal = cm.createFile(file); + console.log("Called createFile for Update which returned " + retVal); + + var file = {uri:rootPath1+"FileUpdate.txt", contents: "Hello Binal"}; + var retVal = cm.updateFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + // Update empty file with blank content + it('Update File With Blank Content', function() { + + var file = {uri:rootPath1+"FileUpdate.txt", contents: " !!"}; + var retVal = cm.updateFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + + var file = {uri:rootPath1 + "FileUpdate.txt"}; + var retVal = cm.deleteFile(file); + + + }); + + }); + + // Open a file + describe('File Open Tests', function() { + + + it('Open File', function() { + + var file = {uri:rootPath1+"FileOpen.txt"}; + var ret = cm.createFile(file); + + var file = {uri:rootPath1+"FileOpen.txt"}; + var retVal = cm.readFile(file); + + expect(retVal.success).toEqual(true); + + expect(retVal.status).toEqual(200); + console.log(retVal.content); + + var file = {uri:rootPath1 + "FileOpen.txt"}; + var retVal = cm.deleteFile(file); + + }); + + }); + + + // Modify a File + describe('File Modified Tests', function() { + + // var retVal = cm.createFile(file); + it('File Modified Test', function() { + var file = {uri:rootPath1 + "ModifyFile.txt", contents:"Hello World!" }; + var file2 = {uri:rootPath1 + "ModifyFile.txt", contents:"Hey World!" } + var retVal = cm.createFile(file); + var dir = {uri:rootPath1}; + var retValDir = cm.getDirectoryContents(dir); + console.log(retValDir); + var myJsonObject = eval('(' + retValDir.content + ')'); + console.log(myJsonObject); + var retVal_update = cm.updateFile(file); + console.log(retVal_update); + var retVal = cm.isFileModified(file,myJsonObject.children[0].modifiedDate); + + console.log(retVal); + expect(retVal.status).toEqual(200); + + }); + + + }); + + + // Modify a Directory + describe('Directory Modified Tests', function() { + + it('Directory Modified Test - file creation', function() { + // debugger; + var file = {uri:rootPath1+ "Myfile1.txt"}; + var dir = {uri:rootPath1}; + console.log(dir); + var retValDir = cm.getDirectoryContents(dir); + console.log(retValDir); + var myJsonObject = eval('(' + retValDir.content + ')'); + var retVal_update = cm.createFile(file); + console.log(myJsonObject); + var retVal = cm.isDirectoryModified(dir,myJsonObject.modifiedDate); + + console.log(retVal); + expect(retVal.status).toEqual(200); + }); + + }); + + + + // File is Writable or not + describe('File Writable Test', function() { + + it('File Writable', function() { + // debugger; + var file = {uri:rootPath1+"NewFile.txt"}; + var dir = {uri:rootPath1}; + var retVal_update = cm.createFile(file); + //var retValDir = cm.getDirectoryContents(dir); + //console.log(retValDir); + // var myJsonObject = eval('(' + retValDir.content + ')'); + //var retVal_update = cm.deleteDirectory(file); + // console.log(myJsonObject); + var retVal = cm.isFileWritable(file); + + console.log(retVal); + expect(retVal.status).toEqual(204); + }); + + }); + + + // Create Directory + describe('Directory Create Tests', function() { + + it('Create Directory', function() { + console.log("14"); + var dir = {uri:rootPath1+"DirCreated"}; + var retVal = cm.createDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(201); + + }); + + + it('Create Existing Directory', function() { + console.log("15"); + var dir = {uri:rootPath1+"DirCreated"}; + + + var retVal = cm.createDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(400); + + }); + + it('Add Files To The Directory', function() { + console.log("16"); + var file= {uri:rootPath1+"DirCreated/DirectoryFile.txt"}; + + var retVal = cm.createFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(201); + + }); + + it('Delete Files From The Directory', function() { + console.log("17"); + var file = {uri:rootPath1+"DirCreated/DirectoryFile.txt"}; + + var retVal = cm.deleteFile(file); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + it('Create Directory Within A Directory', function() { + console.log("18"); + var dir = {uri:rootPath1+"DirCreated/NestedFolder"}; + var retVal = cm.createDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(201); + + var dir = {uri:rootPath1+"DirCreated"}; + var retVal = cm.deleteDirectory(dir); + + }); + + }); + + + // Delete Directory + describe('Directory Delete Tests', function() { + + it('Delete Directory', function() { + + //Deleting a directory with contents is possible with this function + + var dir = {uri:rootPath1+"DirCreated"}; + var retVal = cm.createDirectory(dir); + + console.log("19"); + var dir = {uri:rootPath1+"DirCreated"}; + var retVal = cm.deleteDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + }); + + + // Check if Directory Exists + describe('Directory Exists Tests', function() { + + it('Directory Exists', function() { + + var dir = {uri:rootPath1+"DirExists"}; + var retVal = cm.createDirectory(dir); + console.log("Called createDirectory which returned " + retVal); + + console.log("20"); + var dir = {uri:rootPath1+"DirExists"}; + + var retVal = cm.directoryExists(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + it('Directory Does Not Exists', function() { + console.log("21"); + + var dir = {uri:rootPath1+"DirExists2"}; + + var retVal = cm.directoryExists(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(404); + + var dir = {uri:rootPath1+"DirExists"}; + var retVal = cm.deleteDirectory(dir); + + }); + + }); + + + // Get Directory Content + describe('Get Directory Contents Tests', function() { + + it('Get Directory Contents of Non-Empty Directory', function() { + + var dir = {uri:rootPath1+"DirCreated"}; + var retVal = cm.createDirectory(dir); + var dir = {uri:rootPath1+"DirCreated/NestedFolder"}; + var retVal = cm.createDirectory(dir); + + console.log("22"); + var dir = {uri:rootPath1+"DirCreated"}; + + var retVal = cm.getDirectoryContents(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(200); + console.log(retVal.content); + + }); + + + it('Get Contents of An Empty Directory', function() { + console.log("23"); + + var dir = {uri:rootPath1+"DirCreated/NestedFolder"}; + + var retVal = cm.getDirectoryContents(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(200); + console.log(retVal.content); + + var dir = {uri:rootPath1+"DirCreated"}; + var retVal = cm.deleteDirectory(dir); + + }); + + }); + + + // Copy a Directory + describe('Copy Directory Tests', function() { + + it('Copy Directory', function() { + + var dir = {uri:rootPath1+"DirCopy"}; + var retVal = cm.createDirectory(dir); + + console.log("24"); + + var dir = {sourceUri:"/" + rootPath1+"DirCopy", destUri:rootPath2+"DirCopy" }; + + var retVal = cm.copyDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + + }); + + + it('Copy Directory To A Destination Directory Which Contains Another Directory With The Same Name', function() { + console.log("25"); + var dir = {sourceUri:"/"+rootPath1+"DirCopy", destUri:rootPath2+"DirCopy" }; + + var retVal = cm.copyDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(400); + + }); + + it('Copy Directory To The Same Directory', function() { + console.log("26"); + var dir = {sourceUri:"/"+rootPath1+"DirCopy", destUri:rootPath1+"DirCopy" }; + + var retVal = cm.copyDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(400); + + var dir = {uri:rootPath1+"DirCopy"}; + var retVal = cm.deleteDirectory(dir); + var dir = {uri:rootPath2+"DirCopy"}; + var retVal = cm.deleteDirectory(dir); + + }); + + }); + + + // Move a Directory + describe('Move Directory Tests', function() { + + it('Move Directory', function() { + + var dir = {uri:rootPath1+"DirMove"}; + var ret1 = cm.createDirectory(dir); + + console.log("27"); + + var dir = {sourceUri:"/"+rootPath1+"DirMove", destUri:rootPath2+"DirMove"}; + + var retVal = cm.moveDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(204); + + }); + + it('Move Directory To The Same Directory', function() { + console.log("28"); + var dir = {sourceUri:"/"+rootPath2+"DirMove", destUri:rootPath2+"DirMove" }; + var retVal = cm.moveDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(400); + + }); + + it('Move Directory To A Destination Directory Which Contains Another Directory With The Same Name', function() { + console.log("29"); + var dir = {sourceUri:"/"+rootPath2+"DirMove", destUri:rootPath2+"DirMove" }; + var retVal = cm.moveDirectory(dir); + + expect(retVal.success).toEqual(true); + expect(retVal.status).toEqual(400); + + var dir = {uri:rootPath2+"DirMove"}; + var retVal = cm.deleteDirectory(dir); + + //Optional: Delete the main directories created at the beginning of this file so as to not delete them manually + var dir = {uri:InitDirPath1 + "FileTest1"}; + var retVal = cm.deleteDirectory(dir); + var dir = {uri:InitDirPath1 + "FileTest2"}; + var retVal = cm.deleteDirectory(dir); + + }); + + }); + + +}); +}); + + + + + + + + + + + + + + + + + + + diff --git a/tests/unit-tests/styles-controller-test.js b/tests/unit-tests/styles-controller-test.js new file mode 100644 index 00000000..b98c2f51 --- /dev/null +++ b/tests/unit-tests/styles-controller-test.js @@ -0,0 +1,143 @@ +/** + * Created by JetBrains WebStorm. + * User: kfg834 + * Date: 12/27/11 + * Time: 10:52 AM + * To change this template use File | Settings | File Templates. + */ +var Montage = require("montage/core/core").Montage; +var cmObject = require("ninjaapp/js/controllers/styles-controller"), + cm = cmObject.StylesController; + + +describe('StylesController', function() { + + + function makeAndAppend(tag, attr) { + var el = document.createElement(tag); + if (typeof attr === 'object') { + for (var a in attr) { + if (attr.hasOwnProperty(a)) { + el[a] = attr[a]; + } + } + } else if (typeof attr === 'string') { + el.className = (el.className + ' ' + attr).trim(); + } + + document.body.appendChild(el); + + return el; + } + + /** **************** Rule tests **************** */ + + + /* Add a Rule */ + describe('addRule', function() { + it('Add Rule', function() { + cm.activeDocument = { "_document": document }; + var rule = cm.addRule('div#Div_1 { background-color: rgb(0, 0, 0) }'); + expect(rule.cssText).toEqual("div#Div_1 { background-color: rgb(0, 0, 0); }"); + + }); + + }); + + /* Create OverRide Rule */ + describe('createOverrideRule', function() { + it('Override rule created successfully', function() { + var object = sm.createOverrideRule('div#Div_1 { background-color: black }', 'div'); + expect(object.rule).toEqual("div#Div_1 { background-color: black }"); + + }); + + }); + + + /*Delete a Rule*/ + describe('Delete Rule', function() { + it('Rule deleted successfully', function() { + var index = sm.deleteRule('div#Div_1 { background-color: black }'); + expect(index).toBeGreaterThan(-1); + }); + + }); + + + /* Get Dominant Rule for an Element */ + describe('GetDominantRule-Element', function() { + + it('Got Dominant rule for element successfully', function() { + + var rules = ['div#Div_1 { background-color: black }', + '#UserContent div#Div_1 { background-color: blue }', + '#UserContent #Div_1 { background-color: white }', + 'div div#Div_1 { background-color: red }']; + + rules.forEach(function(rule) { + stylesController.addRule(rule); + }); + + var rule = sm.getDominantRuleForElement('div','background-color',true); + expect(rule).toEqual("#UserContent div#Div_1 { background-color: blue }"); + + }); + + }); + + /* Disable a Rule */ + describe('DisableRule', function() { + + it('Rule disabled successfully', function() { + //Type of rule is not a number + var rule = sm.disableRule('div#Div_1 { background-color: black }'); + expect(rule).toEqual('div#Div_1'+ sm.CONST.GARBAGE_SELECTOR); + + }); + + }); + + + /* Enable a Rule */ + describe('EnableRule', function() { + it('Rule enabled successfully', function() { + + //Type of rule is not a number + var rule = sm.enableRule('div#Div_1 { background-color: black }'); + expect(rule.selectorText).toEqual('div#Div_1'); + + //Type of rule is a number ie index + var rule = sm.enableRule('div#Div_1 { background-color: black }'); + expect(rule).toEqual("div#Div_1 { background-color: black }"); + + }); + + }); + + + /* Set Rule Selector */ + describe('SetRuleSelector', function() { + + it('Set Rule Selector successfully', function() { + var rule = sm.setRuleSelector('div#Div_1 { background-color: black }', 'Div'); + expect(rule).toEqual("Div { background-color: black }"); + expect(rule.specificity.specificity.id).toEqual(0); + //expect(rule.specificity.specificity.class).toEqual(0); + expect(rule.specificity.specificity.element).toEqual(1); + }); + + }); + + + /*Calculate Specificity */ + describe('Calculate Specificity', function() { + + it('Calculated specificity successfully', function() { + var specificity = sm.calculateSpecificity(0,1); + expect(specificity.specificity[2]).toEqual(1); + }); + + }); + +}); \ No newline at end of file -- cgit v1.2.3