flutter/packages/flutter_tools/test/general.shard/web/bootstrap_test.dart
Jonah Williams ed931e7941
initial bootstrap script for incremental compiler support (#43292)
* initial bootstrap script for incremental compiler support

* add more comments

* update to two scripts
2019-10-25 15:03:00 -07:00

36 lines
1.3 KiB
Dart

// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/web/bootstrap.dart';
import '../../src/common.dart';
void main() {
test('generateBootstrapScript embeds urls correctly', () {
final String result = generateBootstrapScript(
requireUrl: 'require.js',
mapperUrl: 'mapper.js',
entrypoint: 'foo/bar/main.js',
);
// require js source is interpolated correctly.
expect(result, contains('requireEl.src = "require.js";'));
// stack trace mapper source is interpolated correctly.
expect(result, contains('mapperEl.src = "mapper.js";'));
// data-main is set to correct bootstrap module.
expect(result, contains('requireEl.setAttribute("data-main", "main_module");'));
// bootstrap main module has correct imports.
expect(result, contains('require(["foo/bar/main.js", "dart_sdk"],'
' function(app, dart_sdk) {'));
});
test('generateMainModule embeds urls correctly', () {
final String result = generateMainModule(
entrypoint: 'foo/bar/main.js',
);
// bootstrap main module has correct defined module.
expect(result, contains('define("main_module", ["foo/bar/main.js", "dart_sdk"], '
'function(app, dart_sdk) {'));
});
}