configuration_test.dart 2.07 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'dart:io';
6

7
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
8 9 10 11 12 13 14 15

import 'package:snippets/configuration.dart';

void main() {
  group('Configuration', () {
    Configuration config;

    setUp(() {
16
      config = Configuration(flutterRoot: Directory('/flutter sdk'));
17 18
    });
    test('config directory is correct', () async {
19 20
      expect(config.configDirectory.path,
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config')));
21 22 23
    });
    test('output directory is correct', () async {
      expect(config.outputDirectory.path,
24
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]docs[/\\]doc[/\\]snippets')));
25 26 27
    });
    test('skeleton directory is correct', () async {
      expect(config.skeletonsDirectory.path,
28
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons')));
29 30 31
    });
    test('templates directory is correct', () async {
      expect(config.templatesDirectory.path,
32
          matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]templates')));
33
    });
34 35
    test('html skeleton file for sample is correct', () async {
      expect(
36
          config.getHtmlSkeletonFile(SnippetType.snippet).path,
37
          matches(RegExp(
38
              r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]snippet.html')));
39 40
    });
    test('html skeleton file for app with no dartpad is correct', () async {
41
      expect(
42
          config.getHtmlSkeletonFile(SnippetType.sample).path,
43
          matches(RegExp(
44
              r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]sample.html')));
45
    });
46 47
    test('html skeleton file for app with dartpad is correct', () async {
      expect(
48
          config.getHtmlSkeletonFile(SnippetType.sample, showDartPad: true).path,
49
          matches(RegExp(
50
              r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]dartpad-sample.html')));
51
    });
52 53
  });
}