-
Notifications
You must be signed in to change notification settings - Fork 1
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 #76 from mrstebo/feature/star-wars
Feature/star wars
- Loading branch information
Showing
7 changed files
with
309 additions
and
0 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,172 @@ | ||
{ | ||
"characters": [ | ||
"Padme Amidala", | ||
"Jar Jar Binks", | ||
"Borvo the Hutt", | ||
"Darth Caedus", | ||
"Boba Fett", | ||
"Jabba the Hutt", | ||
"Obi-Wan Kenobi", | ||
"Darth Maul", | ||
"Leia Organa", | ||
"Sheev Palpatine", | ||
"Kylo Ren", | ||
"Darth Sidious", | ||
"Anakin Skywalker", | ||
"Luke Skywalker", | ||
"Ben Solo", | ||
"Han Solo", | ||
"Darth Vader", | ||
"Watto", | ||
"Mace Windu", | ||
"Yoda", | ||
"Count Dooku", | ||
"Sebulba", | ||
"Qui-Gon Jinn", | ||
"Chewbacca", | ||
"Jango Fett", | ||
"Lando Calrissian", | ||
"Bail Organa", | ||
"Wedge Antilles", | ||
"Poe Dameron", | ||
"Ki-Adi-Mundi", | ||
"Nute Gunray", | ||
"Panaka", | ||
"Rune Haako" | ||
], | ||
"droids": [ | ||
"2-1B", | ||
"4-LOM", | ||
"ASP", | ||
"B2-RP", | ||
"B1", | ||
"BD-3000", | ||
"FA-4", | ||
"GH-7", | ||
"GNK", | ||
"LM-432", | ||
"ID9", | ||
"11-4D", | ||
"2-1B", | ||
"327-T", | ||
"4-LOM", | ||
"B4-D4", | ||
"NR-N99", | ||
"C-3PO", | ||
"R2-D2", | ||
"BB-8", | ||
"R2-Q5" | ||
], | ||
"planets": [ | ||
"Alderaan", | ||
"Bespin", | ||
"Coruscant", | ||
"DQar", | ||
"Dagobah", | ||
"Endor", | ||
"Geonosis", | ||
"Hoth", | ||
"Hosnian Prime", | ||
"Jakku", | ||
"Kamino", | ||
"Kashyyyk", | ||
"Lothal", | ||
"Mustafar", | ||
"Naboo", | ||
"Sullust", | ||
"Takodana", | ||
"Tatooine", | ||
"Utapau", | ||
"Yavin" | ||
], | ||
"quotes": [ | ||
"Never tell me the odds!", | ||
"Well, you said you wanted to be around when I made a mistake.", | ||
"You will never find a more wretched hive of scum and villainy. We must be cautious.", | ||
"Wars not make one great.", | ||
"You do have your moments. Not many, but you have them.", | ||
"Now, witness the power of this fully operational battle station.", | ||
"No reward is worth this.", | ||
"Shut him up or shut him down.", | ||
"I have a bad feeling about this.", | ||
"Who's the more foolish; the fool, or the fool who follows him?", | ||
"Would somebody get this big walking carpet out of my way?", | ||
"I find your lack of faith disturbing.", | ||
"If they follow standard Imperial procedure, they'll dump their garbage before they go to light-speed.", | ||
"Only at the end do you realize the power of the Dark Side.", | ||
"Bounty hunters! We don't need this scum.", | ||
"It's not impossible. I used to bullseye womp rats in my T-16 back home, they're not much bigger than two meters.", | ||
"Strike me down, and I will become more powerful than you could possibly imagine.", | ||
"You know, that little droid is going to cause me a lot of trouble.", | ||
"If you're saying that coming here was a bad idea, I'm starting to agree with you.", | ||
"You'll find I'm full of surprises!", | ||
"Aren't you a little short for a Stormtrooper?", | ||
"You are unwise to lower your defenses!", | ||
"R2-D2, you know better than to trust a strange computer!", | ||
"Truly wonderful, the mind of a child is.", | ||
"That is why you fail.", | ||
"A Jedi uses the Force for knowledge and defense, never for attack.", | ||
"Adventure. Excitement. A Jedi craves not these things.", | ||
"Judge me by my size, do you?", | ||
"Fear is the path to the dark side... fear leads to anger... anger leads to hate... hate leads to suffering.", | ||
"Do. Or do not. There is no try." | ||
], | ||
"species": [ | ||
"Ewok", | ||
"Hutt", | ||
"Gungan", | ||
"Ithorian", | ||
"Jawa", | ||
"Neimoidian", | ||
"Sullustan", | ||
"Wookiee", | ||
"Mon Calamari" | ||
], | ||
"vehicles": [ | ||
"V-Wing Fighter", | ||
"ATT Battle Tank", | ||
"Naboo N-1 Starfighter", | ||
"Vulture Droid", | ||
"Republic Cruiser", | ||
"Naboo Royal Starship", | ||
"Gungan Bongo Submarine", | ||
"Flash Speeder", | ||
"Trade Federation Battleship", | ||
"Millennium Falcon", | ||
"Sith Infiltrator", | ||
"AT-ST Walker", | ||
"TIE Bomber", | ||
"Imperial Shuttle", | ||
"Sandcrawler", | ||
"TIE Interceptor", | ||
"Speeder Bike", | ||
"Death Star", | ||
"AT-AT Walker", | ||
"Imperial Star Destroyer", | ||
"X-Wing Fighter" | ||
], | ||
"wookieWords": [ | ||
"wyaaaaaa", | ||
"ruh", | ||
"huewaa", | ||
"muaa", | ||
"mumwa", | ||
"wua", | ||
"ga", | ||
"ma", | ||
"ahuma", | ||
"ooma", | ||
"youw", | ||
"kabukk", | ||
"wyogg", | ||
"gwyaaaag", | ||
"roooarrgh", | ||
"ur", | ||
"ru", | ||
"roo", | ||
"hnn-rowr", | ||
"yrroonn", | ||
"nng", | ||
"rarr" | ||
] | ||
} |
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,17 @@ | ||
# Faker.StarWars | ||
|
||
```js | ||
Faker.StarWars.character() //=> "Anakin Skywalker" | ||
|
||
Faker.StarWars.droid() //=> "C-3PO" | ||
|
||
Faker.StarWars.planet() //=> "Tatooine" | ||
|
||
Faker.StarWars.quote() //=> "Aren’t you a little short for a Stormtrooper?" | ||
|
||
Faker.StarWars.specie() //=> "Gungan" | ||
|
||
Faker.StarWars.vehicle() //=> "Sandcrawler" | ||
|
||
Faker.StarWars.wookieSentence() //=> "Yrroonn ru ooma roo ahuma ur roooarrgh hnn-rowr." | ||
``` |
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,38 @@ | ||
import data from '../../data/star-wars.json'; | ||
import { randomNumber, itemFromCollection } from '../utils/random'; | ||
|
||
export function character() { | ||
return itemFromCollection(data['characters']); | ||
} | ||
|
||
export function droid() { | ||
return itemFromCollection(data['droids']); | ||
} | ||
|
||
export function planet() { | ||
return itemFromCollection(data['planets']); | ||
} | ||
|
||
export function quote() { | ||
return itemFromCollection(data['quotes']); | ||
} | ||
|
||
export function specie() { | ||
return itemFromCollection(data['species']); | ||
} | ||
|
||
export function vehicle() { | ||
return itemFromCollection(data['vehicles']); | ||
} | ||
|
||
export function wookieSentence() { | ||
return capitalize( | ||
[...Array(randomNumber(1, 10)).keys()] | ||
.map(_ => itemFromCollection(data['wookieWords'])) | ||
.join(' ') + itemFromCollection(['.', '?', '!']) | ||
); | ||
} | ||
|
||
function capitalize(text) { | ||
return text.replace(/\b\w/, x => x.toUpperCase()); | ||
} |
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,73 @@ | ||
'use strict'; | ||
const expect = require('chai').expect; | ||
const StarWars = require('../../src/faker/star-wars'); | ||
const data = require('../../data/star-wars.json'); | ||
|
||
describe('StarWars', () => { | ||
describe('#character', () => { | ||
it('should return a character', () => { | ||
[...Array(100).keys()].forEach(_ => { | ||
expect(StarWars.character()).to.be.oneOf(data['characters']); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#droid', () => { | ||
it('should return a droid', () => { | ||
[...Array(100).keys()].forEach(_ => { | ||
expect(StarWars.droid()).to.be.oneOf(data['droids']); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#planet', () => { | ||
it('should return a planet', () => { | ||
[...Array(100).keys()].forEach(_ => { | ||
expect(StarWars.planet()).to.be.oneOf(data['planets']); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#quote', () => { | ||
it('should return a quote', () => { | ||
[...Array(100).keys()].forEach(_ => { | ||
expect(StarWars.quote()).to.be.oneOf(data['quotes']); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#specie', () => { | ||
it('should return a specie', () => { | ||
[...Array(100).keys()].forEach(_ => { | ||
expect(StarWars.specie()).to.be.oneOf(data['species']); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#vehicle', () => { | ||
it('should return a vehicle', () => { | ||
[...Array(100).keys()].forEach(_ => { | ||
expect(StarWars.vehicle()).to.be.oneOf(data['vehicles']); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#wookieSentence', () => { | ||
it('should return wookie words', () => { | ||
StarWars.wookieSentence() | ||
.split(/(?:\s|[.?!])/) // remove endings | ||
.filter(x => x) | ||
.forEach(word => { | ||
expect(word.toLowerCase()).to.be.oneOf(data['wookieWords']); | ||
}); | ||
}); | ||
|
||
it('should start with a capital letter', () => { | ||
expect(StarWars.wookieSentence()).to.match(/^[A-Z]/); | ||
}); | ||
|
||
it('should end with period, question mark or explanation mark', () => { | ||
expect(StarWars.wookieSentence()).to.match(/[.?!]$/); | ||
}); | ||
}); | ||
}); |