-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
90 additions
and
55 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
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,64 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var s18n = require('../'); | ||
|
||
describe('s18n.extract()', function() { | ||
|
||
it('should have an "extract" method', function() { | ||
assert.equal(typeof s18n, 'object'); | ||
assert.equal(typeof s18n.extract, 'function'); | ||
}); | ||
|
||
it('should extract locale strings from configured html attributes', function() { | ||
var html = '<img src="example.gif" data-custom="custom attribute">'; | ||
var locale = s18n.extract(html, { | ||
attributes: ['data-custom'] | ||
}); | ||
assert.deepEqual(JSON.parse(locale), { | ||
'89f8af89':'custom attribute' | ||
}); | ||
}); | ||
|
||
it('should extract locale strings from configured html elements', function() { | ||
var html = '<h1>heading</h1><custom>Custom element</custom>'; | ||
var locale = s18n.extract(html, { | ||
elements: ['custom'] | ||
}); | ||
assert.deepEqual(JSON.parse(locale), { | ||
'74251aeb':'Custom element' | ||
}); | ||
}); | ||
|
||
it('should extract locale strings from html elements with configured directives', function() { | ||
var html = '<div localize>This is a test.</div><div custom>custom directive</div>'; | ||
var locale = s18n.extract(html, { | ||
directives : ['localize', 'custom'] | ||
}); | ||
assert.deepEqual(JSON.parse(locale), { | ||
'120ea8a2':'This is a test.', | ||
'6bd3b8ac':'custom directive' | ||
}); | ||
}); | ||
|
||
it('should allow other hash algorithms', function() { | ||
var html = '<p>This is a test.</p>'; | ||
var locale = s18n.extract(html, { | ||
hashAlgorithm : 'rmd160' | ||
}); | ||
assert.deepEqual(JSON.parse(locale), { | ||
'3c82f755':'This is a test.' | ||
}); | ||
}); | ||
|
||
it('should allow for different hash lengths', function() { | ||
var html = '<p>This is a test.</p>'; | ||
var locale = s18n.extract(html, { | ||
hashLength : 13 | ||
}); | ||
assert.deepEqual(JSON.parse(locale), { | ||
'120ea8a25e5d4':'This is a test.' | ||
}); | ||
}); | ||
|
||
}); |
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,13 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var s18n = require('../'); | ||
|
||
describe('s18n.localize()', function() { | ||
|
||
it('should have a "localize" method', function() { | ||
assert.equal(typeof s18n, 'object'); | ||
assert.equal(typeof s18n.extract, 'function'); | ||
}); | ||
|
||
}); |
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,13 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var s18n = require('../'); | ||
|
||
describe('s18n.map()', function() { | ||
|
||
it('should have a "map" method', function() { | ||
assert.equal(typeof s18n, 'object'); | ||
assert.equal(typeof s18n.extract, 'function'); | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.