-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write tests for JSONFileLoader and TranslationsLoader
- Loading branch information
Showing
10 changed files
with
202 additions
and
9 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
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,28 @@ | ||
// | ||
// ExpressionsLoaderTests.swift | ||
// Swifternalization | ||
// | ||
// Created by Tomasz Szulc on 21/07/15. | ||
// Copyright (c) 2015 Tomasz Szulc. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import XCTest | ||
|
||
class ExpressionsLoaderTests: XCTestCase { | ||
|
||
func testShouldLoadBase() { | ||
let content = ExpressionsLoader.loadExpressions("base", bundle: NSBundle.testBundle()) | ||
XCTAssertTrue(content.count > 0, "") | ||
} | ||
|
||
func testShouldLoadPL() { | ||
let content = ExpressionsLoader.loadExpressions("pl", bundle: NSBundle.testBundle()) | ||
XCTAssertTrue(content.count > 0, "") | ||
} | ||
|
||
func testShouldNotLoadDE() { | ||
let content = ExpressionsLoader.loadExpressions("de", bundle: NSBundle.testBundle()) | ||
XCTAssertFalse(content.count > 0, "") | ||
} | ||
} |
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,23 @@ | ||
// | ||
// JSONFileLoaderTests.swift | ||
// Swifternalization | ||
// | ||
// Created by Tomasz Szulc on 21/07/15. | ||
// Copyright (c) 2015 Tomasz Szulc. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import XCTest | ||
|
||
class JSONFileLoaderTests: XCTestCase { | ||
|
||
func testJSONShouldBeLoaded() { | ||
let content = JSONFileLoader.load("base", bundle: NSBundle.testBundle()) | ||
XCTAssertNotNil(content!, "") | ||
} | ||
|
||
func testFileShouldNotBeLoaded() { | ||
let content = JSONFileLoader.load("not-existing", bundle: NSBundle.testBundle()) | ||
XCTAssertNil(content, "") | ||
} | ||
} |
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,15 @@ | ||
// | ||
// NSBundle+TestExtension.swift | ||
// Swifternalization | ||
// | ||
// Created by Tomasz Szulc on 21/07/15. | ||
// Copyright (c) 2015 Tomasz Szulc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension NSBundle { | ||
class func testBundle() -> NSBundle { | ||
return NSBundle(forClass: JSONFileLoaderTests.self) | ||
} | ||
} |
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,28 @@ | ||
{ | ||
"welcome": "welcome", | ||
|
||
"cars": { | ||
"one": "1 car", | ||
"ie:x=2": "2 cars", | ||
"more": "%d cars" | ||
}, | ||
|
||
"forgot-password": { | ||
"@100": "Forgot Password? Help.", | ||
"@200": "Forgot Password? Get password Help.", | ||
"@300": "Forgotten Your Password? Get password Help." | ||
}, | ||
|
||
"car-sentence": { | ||
"one": { | ||
"@100": "one car", | ||
"@200": "just one car", | ||
"@300": "you've got just one car" | ||
}, | ||
|
||
"more": { | ||
"@100": "%d cars", | ||
"@300": "you've got %d cars" | ||
} | ||
} | ||
} |
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,11 @@ | ||
{ | ||
"base": { | ||
"one": "ie:x=1", | ||
"two": "ie:x=2", | ||
"more": "exp:(^[^1])|(^\\d{2,})" | ||
}, | ||
|
||
"pl": { | ||
"few": "exp:(((?!1).[2-4]{1})$)|(^[2-4]$)" | ||
} | ||
} |
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,28 @@ | ||
{ | ||
"welcome": "witaj", | ||
|
||
"cars": { | ||
"one": "1 samochód", | ||
"ie:x=2": "2 samochody", | ||
"more": "%d samochodów" | ||
}, | ||
|
||
"forgot-password": { | ||
"@100": "Zapomniałeś hasła? Pomoc.", | ||
"@200": "Zapomniałeś hasła? Skorzystaj z Pomocy.", | ||
"@300": "Zapomniałeś swojego hasła? Skorzystaj z pomocy." | ||
}, | ||
|
||
"car-sentence": { | ||
"one": { | ||
"@100": "jeden samochód", | ||
"@200": "tylko jeden samochód", | ||
"@300": "posiadasz tylko jeden samochód" | ||
}, | ||
|
||
"more": { | ||
"@100": "%d samochodów", | ||
"@300": "posiadasz %d samochodów" | ||
} | ||
} | ||
} |