OnValid() public method

public OnValid ( JToken e ) : void
e JToken
return void
Beispiel #1
0
        public async Task DevServer_EmitsOnValid()
        {
            // Arrange
            var mock = new WebpackServiceMock();

            mock.AddFile("/public/bundle.js", "bundle.js", "js");

            using (var server = CreateServer(mock))
            {
                using (var client = server.CreateClient())
                {
                    // Act
                    var stream = await client.GetStreamAsync("/__webpack_hmr");

                    var buffer     = new byte[256];
                    var byteCount1 = await stream.ReadAsync(buffer, 0, 256);

                    Assert.Equal(14, byteCount1);

                    var e = new JObject();
                    mock.OnValid(e);

                    // TODO
                    var byteCount2 = await stream.ReadAsync(buffer, 0, 256);

                    Assert.Equal(28, byteCount2);
                    Assert.Equal("data: {\"action\":\"built\"}\r\n\r\n", System.Text.Encoding.UTF8.GetString(buffer).Substring(0, byteCount2));
                }
            }
        }
        public async Task HotReload_EmitsOnValid()
        {
            var mock = new WebpackServiceMock();

            mock.AddFile("/public/bundle.js", "bundle.js", "js");

            using (var server = CreateServer(mock))
            {
                using (var client = server.CreateClient())
                {
                    client.DefaultRequestHeaders.Add("Accept", "text/event-stream");
                    var stream = await client.GetStreamAsync("/__webpack_hmr");

                    var buffer     = new byte[256];
                    var byteCount1 = await stream.ReadAsync(buffer, 0, 256);

                    Assert.Equal(14, byteCount1);

                    var e = new JArray();
                    e.Add(new JObject());
                    mock.OnValid(e);

                    // TODO
                    var byteCount2 = await stream.ReadAsync(buffer, 0, 256);

                    Assert.Equal(28, byteCount2);
                    Assert.Equal("data: {\"action\":\"built\"}\r\n\r\n", System.Text.Encoding.UTF8.GetString(buffer).Substring(0, byteCount2));
                }
            }
        }
        public async Task DevServer_EmitsOnValid()
        {
            // Arrange
            var mock = new WebpackServiceMock();
            mock.AddFile("/public/bundle.js", "bundle.js", "js");

            using (var server = CreateServer(mock))
            {
                using (var client = server.CreateClient())
                {
                    // Act
                    var stream = await client.GetStreamAsync("/__webpack_hmr");

                    var buffer = new byte[256];
                    var byteCount1 = await stream.ReadAsync(buffer, 0, 256);
                    Assert.Equal(14, byteCount1);

                    var e = new JObject();
                    mock.OnValid(e);

                    // TODO
                    var byteCount2 = await stream.ReadAsync(buffer, 0, 256);
                    Assert.Equal(28, byteCount2);
                    Assert.Equal("data: {\"action\":\"built\"}\r\n\r\n", System.Text.Encoding.UTF8.GetString(buffer).Substring(0, byteCount2));
                }
            }
        }