Skip to content

Commit

Permalink
fix: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoDanin committed Feb 10, 2019
1 parent 054aae0 commit 409184a
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 45 deletions.
26 changes: 26 additions & 0 deletions test/fixtures/file00.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-11 14:01-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: test_fixtures_file02.js:1
msgid "world"
msgstr "mundo"

#: test_fixtures_file02.js:2
msgid "Hello {{0}}"
msgstr "Olá {{0}}"
23 changes: 4 additions & 19 deletions test/fixtures/file01.po
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-11 14:01-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: UTF-8\n"

#: test_fixtures_file01.js:1
msgid "Hello {{0}}"
#: test/fixtures/file01.js:1:1
msgid "Hello ${0}"
msgstr ""

11 changes: 11 additions & 0 deletions test/fixtures/file02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_'Test1'
_`Test2 ${a} s`
_`Test3 ${a} ${b}`
i18n`Test4 ${a} ${b} ${c}`
_`Test5 ${a ? true : `FALSE`} ${b}`
_`Test6`
_"Test 7"
//i18n: 123
_"Test 8"

"test 9"
59 changes: 35 additions & 24 deletions test/fixtures/file02.po
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-11 14:01-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: test_fixtures_file02.js:1
msgid "world"
msgstr "mundo"

#: test_fixtures_file02.js:2
msgid "Hello {{0}}"
msgstr "Olá {{0}}"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: UTF-8\n"

#: test/fixtures/file02.js:1:1
msgid "Test1"
msgstr ""

#: test/fixtures/file02.js:2:1
msgid "Test2 ${0} s"
msgstr ""

#: test/fixtures/file02.js:3:1
msgid "Test3 ${0} ${1}"
msgstr ""

#: test/fixtures/file02.js:4:4
msgid "Test4 ${0} ${1} ${2}"
msgstr ""

#: test/fixtures/file02.js:5:1
msgid "Test5 ${0} ${1}"
msgstr ""

#: test/fixtures/file02.js:6:1
msgid "Test6"
msgstr ""

#: test/fixtures/file02.js:7:1
msgid "Test 7"
msgstr ""

#: test/fixtures/file02.js:9:1
#. 123
msgid "Test 8"
msgstr ""
9 changes: 9 additions & 0 deletions test/fixtures/file03.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'Test1'
`Test2 ${a} s`
`Test3 ${a} ${b}`
`Test4 ${a} ${b} ${c}`
`Test5 ${a ? true : `FALSE`} ${b}`
`Test6`
"Test 7"
//i18n: 123
"Test 8"
37 changes: 37 additions & 0 deletions test/fixtures/file03.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: UTF-8\n"

#: test/fixtures/file03.js:1:0
msgid "Test1"
msgstr ""

#: test/fixtures/file03.js:2:0
msgid "Test2 ${0} s"
msgstr ""

#: test/fixtures/file03.js:3:0
msgid "Test3 ${0} ${1}"
msgstr ""

#: test/fixtures/file03.js:4:0
msgid "Test4 ${0} ${1} ${2}"
msgstr ""

#: test/fixtures/file03.js:5:0
msgid "Test5 ${0} ${1}"
msgstr ""

#: test/fixtures/file03.js:6:0
msgid "Test6"
msgstr ""

#: test/fixtures/file03.js:7:0
msgid "Test 7"
msgstr ""

#: test/fixtures/file03.js:9:0
#. 123
msgid "Test 8"
msgstr ""
14 changes: 12 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ var r

describe('Cli Test', () => {
it('Create file01.po', async () => {"POT-Creation-Date: 2018-10-11 14:01-0300\n"
var { stdout } = await exec('find . | grep test/fixtures/file01.js | sort | node cli.js')
var { stdout } = await exec('find . | grep test/fixtures/file01.js | node cli.js')
var removeDate = (text) => text.replace(/POT-Creation-Date.*"/g, '')
assert.equal(removeDate(stdout), removeDate(fs.readFileSync('test/fixtures/file01.po').toString()))
})
it('Create file02.po', async () => {"POT-Creation-Date: 2018-10-11 14:01-0300\n"
var { stdout } = await exec('find . | grep test/fixtures/file02.js | node cli.js')
var removeDate = (text) => text.replace(/POT-Creation-Date.*"/g, '')
assert.equal(removeDate(stdout), removeDate(fs.readFileSync('test/fixtures/file02.po').toString()))
})
it('All strings', async () => {"POT-Creation-Date: 2018-10-11 14:01-0300\n"
var { stdout } = await exec('find . | grep test/fixtures/file03.js | node cli.js --all')
var removeDate = (text) => text.replace(/POT-Creation-Date.*"/g, '')
assert.equal(removeDate(stdout), removeDate(fs.readFileSync('test/fixtures/file03.po').toString()))
})
})

describe('Resources Test', () => {
it('Create config', async () => {
r = new Resources()
})
it('Load resource (pt.po)', async () => {
r.load('pt', 'test/fixtures/file02.po')
r.load('pt', 'test/fixtures/file00.po')
})
})

Expand Down

0 comments on commit 409184a

Please sign in to comment.