react-native/local-cli/__tests__/generator-android-test.js
Martin Konicek 42eb5464fd Release React Native for Android
This is an early release and there are several things that are known
not to work if you're porting your iOS app to Android.

See the Known Issues guide on the website.

We will work with the community to reach platform parity with iOS.
2015-09-14 18:13:39 +01:00

78 lines
2.9 KiB
JavaScript

'use strict';
jest.autoMockOff();
var path = require('path');
describe('react:android', function () {
var assert = require('yeoman-generator').assert;
beforeEach(function (done) {
var helpers = require('yeoman-generator').test;
var generated = false;
runs(function() {
helpers.run(path.resolve(__dirname, '..', 'generator-android'))
.withArguments(['TestApp'])
.withOptions({
'package': 'com.reactnative.test',
})
.on('end', function() {
generated = true;
});
});
waitsFor(function() {
jest.runAllTicks();
jest.runOnlyPendingTimers();
return generated;
}, "generation", 750);
});
it('creates files', function () {
assert.file([
path.join('android', 'build.gradle'),
path.join('android', 'gradle.properties'),
path.join('android', 'gradlew.bat'),
path.join('android', 'gradlew'),
path.join('android', 'settings.gradle'),
path.join('android', 'app', 'build.gradle'),
path.join('android', 'app', 'proguard-rules.pro'),
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-hdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-mdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-xhdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-xxhdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
path.join('android', 'app', 'src', 'main', 'res', 'values', 'styles.xml'),
path.join('android', 'gradle', 'wrapper', 'gradle-wrapper.jar'),
path.join('android', 'gradle', 'wrapper', 'gradle-wrapper.properties')
]);
});
it('replaces variables', function() {
assert.fileContent(path.join('android', 'app', 'build.gradle'), 'applicationId "com.reactnative.test"');
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
'package="com.reactnative.test"'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
'name=".MainActivity"'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
'package com.reactnative.test;'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
'mReactRootView.startReactApplication(mReactInstanceManager, "TestApp", null);'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
'<string name="app_name">TestApp</string>'
);
});
});