add prettier and eslint
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
describe("jasmineUnderTest.util", function() {
|
||||
describe("isArray_", function() {
|
||||
it("should return true if the argument is an array", function() {
|
||||
describe('jasmineUnderTest.util', function() {
|
||||
describe('isArray_', function() {
|
||||
it('should return true if the argument is an array', function() {
|
||||
expect(jasmineUnderTest.isArray_([])).toBe(true);
|
||||
expect(jasmineUnderTest.isArray_(['a'])).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false if the argument is not an array", function() {
|
||||
it('should return false if the argument is not an array', function() {
|
||||
expect(jasmineUnderTest.isArray_(undefined)).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_({})).toBe(false);
|
||||
expect(jasmineUnderTest.isArray_(function() {})).toBe(false);
|
||||
@@ -15,13 +15,13 @@ describe("jasmineUnderTest.util", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isObject_", function() {
|
||||
it("should return true if the argument is an object", function() {
|
||||
describe('isObject_', function() {
|
||||
it('should return true if the argument is an object', function() {
|
||||
expect(jasmineUnderTest.isObject_({})).toBe(true);
|
||||
expect(jasmineUnderTest.isObject_({an: "object"})).toBe(true);
|
||||
expect(jasmineUnderTest.isObject_({ an: 'object' })).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false if the argument is not an object", function() {
|
||||
it('should return false if the argument is not an object', function() {
|
||||
expect(jasmineUnderTest.isObject_(undefined)).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_([])).toBe(false);
|
||||
expect(jasmineUnderTest.isObject_(function() {})).toBe(false);
|
||||
@@ -31,128 +31,126 @@ describe("jasmineUnderTest.util", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("promise utils", function () {
|
||||
describe('promise utils', function() {
|
||||
var mockNativePromise, mockPromiseLikeObject;
|
||||
|
||||
var mockNativePromise,
|
||||
mockPromiseLikeObject;
|
||||
var mockPromiseLike = function() {
|
||||
this.then = function() {};
|
||||
};
|
||||
|
||||
var mockPromiseLike = function () {this.then = function () {};};
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
mockNativePromise = new Promise(function (res, rej) {});
|
||||
mockNativePromise = new Promise(function(res, rej) {});
|
||||
mockPromiseLikeObject = new mockPromiseLike();
|
||||
});
|
||||
|
||||
describe("isPromise", function () {
|
||||
|
||||
it("should return true when passed a native promise", function () {
|
||||
describe('isPromise', function() {
|
||||
it('should return true when passed a native promise', function() {
|
||||
expect(jasmineUnderTest.isPromise(mockNativePromise)).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false for promise like objects", function () {
|
||||
it('should return false for promise like objects', function() {
|
||||
expect(jasmineUnderTest.isPromise(mockPromiseLikeObject)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for strings", function () {
|
||||
expect(jasmineUnderTest.isPromise("hello")).toBe(false);
|
||||
it('should return false for strings', function() {
|
||||
expect(jasmineUnderTest.isPromise('hello')).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for numbers", function () {
|
||||
it('should return false for numbers', function() {
|
||||
expect(jasmineUnderTest.isPromise(3)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for null", function () {
|
||||
it('should return false for null', function() {
|
||||
expect(jasmineUnderTest.isPromise(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for undefined", function () {
|
||||
it('should return false for undefined', function() {
|
||||
expect(jasmineUnderTest.isPromise(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for arrays", function () {
|
||||
it('should return false for arrays', function() {
|
||||
expect(jasmineUnderTest.isPromise([])).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for objects", function () {
|
||||
it('should return false for objects', function() {
|
||||
expect(jasmineUnderTest.isPromise({})).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for boolean values", function () {
|
||||
it('should return false for boolean values', function() {
|
||||
expect(jasmineUnderTest.isPromise(true)).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("isPromiseLike", function () {
|
||||
|
||||
it("should return true when passed a native promise", function () {
|
||||
describe('isPromiseLike', function() {
|
||||
it('should return true when passed a native promise', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(mockNativePromise)).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true for promise like objects", function () {
|
||||
expect(jasmineUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe(true);
|
||||
it('should return true for promise like objects', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(mockPromiseLikeObject)).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it("should return false if then is not a function", function () {
|
||||
expect(jasmineUnderTest.isPromiseLike({then:{its:"Not a function :O"}})).toBe(false);
|
||||
it('should return false if then is not a function', function() {
|
||||
expect(
|
||||
jasmineUnderTest.isPromiseLike({ then: { its: 'Not a function :O' } })
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for strings", function () {
|
||||
expect(jasmineUnderTest.isPromiseLike("hello")).toBe(false);
|
||||
it('should return false for strings', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike('hello')).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for numbers", function () {
|
||||
it('should return false for numbers', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(3)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for null", function () {
|
||||
it('should return false for null', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for undefined", function () {
|
||||
it('should return false for undefined', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for arrays", function () {
|
||||
it('should return false for arrays', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike([])).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for objects", function () {
|
||||
it('should return false for objects', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike({})).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false for boolean values", function () {
|
||||
it('should return false for boolean values', function() {
|
||||
expect(jasmineUnderTest.isPromiseLike(true)).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("isUndefined", function() {
|
||||
it("reports if a variable is defined", function() {
|
||||
describe('isUndefined', function() {
|
||||
it('reports if a variable is defined', function() {
|
||||
var a;
|
||||
expect(jasmineUnderTest.util.isUndefined(a)).toBe(true);
|
||||
expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(true);
|
||||
|
||||
var undefined = "diz be undefined yo";
|
||||
var undefined = 'diz be undefined yo';
|
||||
expect(jasmineUnderTest.util.isUndefined(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getPropertyDescriptor", function() {
|
||||
it("get property descriptor from object", function() {
|
||||
var obj = {prop: 1},
|
||||
describe('getPropertyDescriptor', function() {
|
||||
it('get property descriptor from object', function() {
|
||||
var obj = { prop: 1 },
|
||||
actual = jasmineUnderTest.util.getPropertyDescriptor(obj, 'prop'),
|
||||
expected = Object.getOwnPropertyDescriptor(obj, 'prop');
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it("get property descriptor from object property", function() {
|
||||
var proto = {prop: 1},
|
||||
obj = Object.create(proto),
|
||||
it('get property descriptor from object property', function() {
|
||||
var proto = { prop: 1 },
|
||||
actual = jasmineUnderTest.util.getPropertyDescriptor(proto, 'prop'),
|
||||
expected = Object.getOwnPropertyDescriptor(proto, 'prop');
|
||||
|
||||
@@ -160,8 +158,8 @@ describe("jasmineUnderTest.util", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("objectDifference", function() {
|
||||
it("given two objects A and B, returns the properties in A not present in B", function() {
|
||||
describe('objectDifference', function() {
|
||||
it('given two objects A and B, returns the properties in A not present in B', function() {
|
||||
var a = {
|
||||
foo: 3,
|
||||
bar: 4,
|
||||
@@ -173,10 +171,13 @@ describe("jasmineUnderTest.util", function() {
|
||||
quux: 7
|
||||
};
|
||||
|
||||
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({foo: 3, baz: 5})
|
||||
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({
|
||||
foo: 3,
|
||||
baz: 5
|
||||
});
|
||||
});
|
||||
|
||||
it("only looks at own properties of both objects", function() {
|
||||
it('only looks at own properties of both objects', function() {
|
||||
function Foo() {}
|
||||
|
||||
Foo.prototype.x = 1;
|
||||
@@ -188,13 +189,13 @@ describe("jasmineUnderTest.util", function() {
|
||||
var b = new Foo();
|
||||
b.y = 2;
|
||||
|
||||
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({x: 1});
|
||||
expect(jasmineUnderTest.util.objectDifference(b, a)).toEqual({y: 2});
|
||||
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({ x: 1 });
|
||||
expect(jasmineUnderTest.util.objectDifference(b, a)).toEqual({ y: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("jasmineFile", function() {
|
||||
it("returns the file containing jasmine.util", function() {
|
||||
describe('jasmineFile', function() {
|
||||
it('returns the file containing jasmine.util', function() {
|
||||
// Chrome sometimes reports foo.js as foo.js/, so tolerate
|
||||
// a trailing slash if present.
|
||||
expect(jasmineUnderTest.util.jasmineFile()).toMatch(/util.js\/?$/);
|
||||
|
||||
Reference in New Issue
Block a user