Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from typekit/bs-jasmine
Convert unit tests to Jasmine
- Loading branch information
Showing
51 changed files
with
6,719 additions
and
3,734 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
source :gemcutter | ||
source :rubygems | ||
|
||
gem "rake" | ||
|
||
group :demos do | ||
gem "rack" | ||
gem "sinatra" | ||
gem "vegas" | ||
end | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
describe('AscenderScript', function () { | ||
var AscenderScript = webfont.AscenderScript; | ||
|
||
var configuration = { | ||
key: 'ec2de397-11ae-4c10-937f-bf94283a70c1', | ||
families: ['AndyBold', 'Arial:bold,regular'] | ||
}; | ||
|
||
describe('load family and variations', function () { | ||
var fakeDomHelper = null, | ||
fakeOnReady = null, | ||
ascenderScript = null; | ||
|
||
beforeEach(function () { | ||
fakeDomHelper = { | ||
insertInto: jasmine.createSpy('insertInto'), | ||
createCssLink: jasmine.createSpy('createCssLink'), | ||
getProtocol: jasmine.createSpy('getProtocol').andReturn('http:') | ||
}; | ||
|
||
fakeOnReady = jasmine.createSpy('onReady'); | ||
|
||
ascenderScript = new AscenderScript(fakeDomHelper, configuration); | ||
ascenderScript.load(fakeOnReady); | ||
}); | ||
|
||
it('should create the link correctly', function () { | ||
expect(fakeDomHelper.createCssLink).toHaveBeenCalledWith('http://webfonts.fontslive.com/css/ec2de397-11ae-4c10-937f-bf94283a70c1.css'); | ||
expect(fakeDomHelper.insertInto.calls[0].args[0]).toEqual('head'); | ||
}); | ||
|
||
it('should parse variations correctly', function () { | ||
expect(ascenderScript.parseVariations('regular')).toEqual(['n4']); | ||
expect(ascenderScript.parseVariations('bold')).toEqual(['n7']); | ||
expect(ascenderScript.parseVariations('italic')).toEqual(['i4']); | ||
expect(ascenderScript.parseVariations('bolditalic')).toEqual(['i7']); | ||
expect(ascenderScript.parseVariations('regular,')).toEqual(['n4']); | ||
expect(ascenderScript.parseVariations('regular,bold')).toEqual(['n4', 'n7']); | ||
expect(ascenderScript.parseVariations('regular,,bold')).toEqual(['n4', 'n7']); | ||
expect(ascenderScript.parseVariations('n4,n7')).toEqual(['n4', 'n7']); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
describe('CssClassName', function () { | ||
var CssClassName = webfont.CssClassName, | ||
sanitizer = new CssClassName(); | ||
|
||
describe('#sanitize', function () { | ||
it('should sanitize spaces in names', function () { | ||
expect(sanitizer.sanitize(' My Family ')).toEqual('myfamily'); | ||
}); | ||
|
||
it('should sanitize numbers in names', function () { | ||
expect(sanitizer.sanitize('99 My Family 99')).toEqual('99myfamily99');; | ||
}); | ||
|
||
it('should sanitize other characters', function () { | ||
expect(sanitizer.sanitize('_My+Family!-')).toEqual('myfamily'); | ||
}); | ||
}); | ||
|
||
describe('#build', function () { | ||
it('should build many parts', function () { | ||
expect(sanitizer.build('pre_', 'My Family', '_post')).toEqual('pre-myfamily-post'); | ||
}); | ||
|
||
it('should build some parts', function () { | ||
expect(sanitizer.build('pre!', 'My Family')).toEqual('pre-myfamily'); | ||
}); | ||
}); | ||
|
||
describe('#constructor', function () { | ||
it('should use a hyphen as a default separator', function () { | ||
var sanitizer = new CssClassName(); | ||
|
||
expect(sanitizer.build('pre', 'post')).toEqual('pre-post'); | ||
}); | ||
|
||
it('should use the configured separator', function () { | ||
var sanitizer = new CssClassName('_'); | ||
|
||
expect(sanitizer.build('pre', 'post')).toEqual('pre_post'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
describe('CssFontFamilyName', function () { | ||
var CssFontFamilyName = webfont.CssFontFamilyName, | ||
sanitizer = new CssFontFamilyName(); | ||
|
||
describe('#quote', function () { | ||
it('should quote names with spaces', function () { | ||
expect(sanitizer.quote('My Family')).toEqual("'My Family'"); | ||
}); | ||
|
||
it('should quote names with spaces and double quotes', function () { | ||
expect(sanitizer.quote('"My Family"')).toEqual("'My Family'"); | ||
}); | ||
|
||
it('should quote names with spaces and single quotes', function () { | ||
expect(sanitizer.quote("'My Family'")).toEqual("'My Family'"); | ||
}); | ||
|
||
it('should quote multiple single quoted names separated with a comma', function () { | ||
expect(sanitizer.quote("'family 1','family 2'")).toEqual("'family 1','family 2'"); | ||
}); | ||
|
||
it('should quote multiple single quoted names separated with a comma and space', function () { | ||
expect(sanitizer.quote("'family 1', 'family 2'")).toEqual("'family 1','family 2'"); | ||
}); | ||
|
||
it('should not quote when there is no space', function () { | ||
expect(sanitizer.quote('MyFamily')).toEqual('MyFamily'); | ||
}); | ||
|
||
it('should remove quotes when they are unnecesssary', function () { | ||
expect(sanitizer.quote('"MyFamily"')).toEqual('MyFamily'); | ||
}); | ||
|
||
it('should not quote multiple names when there is no space', function () { | ||
expect(sanitizer.quote("'family-1', 'family-2'")).toEqual('family-1,family-2'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.